//
//  SetUserPositionView.swift
//  IdleFish
//
//  Created by Ben on 2022/1/16.
//

import SwiftUI

let POSITION_SOURCE: [String] = [
    "行政",
    "创始人",
    "高管",
    "职业经理人",
    "市场",
    "销售",
    "人力资源",
    "公关",
    "客服",
    "财务",
    "法务",
    "工程师",
    "设计师",
    "分析师",
    "产品经理",
    "咨询顾问",
    "研究员",
    "教师",
    "演员",
    "教练"
]

struct SetUserPositionView: View {
    
    @EnvironmentObject var userDataVM: UserDataViewModel

    
    var body: some View {
        
        VStack(alignment: .leading) {
            // 这里添加一个右侧的按钮
            CustomNavView(title: "选择职业") {
                userDataVM.showIndustryPicker.toggle()
            }
            
            List(POSITION_SOURCE, id: \.self) { position in
                HStack {
                    Text(position)
                        .font(.system(size: 16, weight: userDataVM.initVM?.userInfo?.position == position ? .bold : .regular))
                    
                    Spacer()
                    
                    Image(systemName: "checkmark")
                        .font(.system(size: 14))
                        .opacity(userDataVM.initVM?.userInfo?.position == position ? 1 : 0)
                }
                .contentShape(Rectangle())
                .frame(height: 45)
                .listRowSeparator(.hidden)
                .onTapGesture {
                    userDataVM.selectedPosition = position
                    
                }
            }
            .listStyle(.plain)
        }
        .navigationBarHidden(true)
        .navigationTitle("")
    }

}

struct SetUserPositionView_Previews: PreviewProvider {
    static var previews: some View {
        SetUserPositionView()
    }
}
